home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / croutes.zip / GREP.DOC < prev    next >
Text File  |  1983-12-18  |  3KB  |  86 lines

  1.                   GREP  --  File Scan Utility
  2.                   ===========================
  3.  
  4.  
  5. Converted to IBM PC CI-C86 C Compiler June 1983 by David N. Smith
  6.  
  7. Originally distributed by DECUS.
  8.  
  9. Neither Digital Equipment Corporation, DECUS, nor the authors assume any
  10. responsibility for the use or reliability of this document or the described
  11. software.
  12.  
  13. Copyright (C) 1980, DECUS
  14.  
  15. General permission to copy or modify, but not for profit, is hereby granted,
  16. provided that the above copyright notice is included and reference made to
  17. the fact that reproduction privileges were granted by DECUS.
  18.  
  19.  
  20. Using GREP
  21. ----------
  22.  
  23. grep searches a file for a given pattern.  Execute by:
  24.  
  25.    grep [flags] regular_expression file_list
  26.  
  27.  
  28. Flags are single characters preceeded by '-':
  29.  
  30.    -c      Only a count of matching lines is printed
  31.    -f      Print file name for matching lines switch, see below
  32.    -n      Each line is preceeded by its line number
  33.    -v      Only print non-matching lines
  34.  
  35. The file_list is a list of files.
  36.  
  37. The file name is normally printed if there is a file given.
  38. The -f flag reverses this action (print name no file, not if
  39. more).
  40.  
  41.  
  42.  
  43. Regular Expressions
  44. -------------------
  45.  
  46. The regular_expression defines the pattern to search for.  Upper- and
  47. lower-case are always ignored.  Blank lines never match.  The expression
  48. should be quoted to prevent file-name translation.
  49.  
  50. x      An ordinary character (not mentioned below) matches that character.
  51.  
  52. '\'    The backslash quotes any character.  "\$" matches a dollar-sign.
  53.  
  54. '^'    A circumflex at the beginning of an expression matches the
  55.        beginning of a line.
  56.  
  57. '$'    A dollar-sign at the end of an expression matches the end of a line.
  58.  
  59. '.'    A period matches any character except "new-line".
  60.  
  61. ':a'   A colon matches a class of characters described by the following
  62. ':d'     character.  ":a" matches any alphabetic, ":d" matches digits,
  63. ':n'     ":n" matches alphanumerics, ": " matches spaces, tabs, and
  64. ': '     other control characters, such as new-line.
  65.  
  66. '*'    An expression followed by an asterisk matches zero or more
  67.        occurrances of that expression: "fo*" matches "f", "fo"
  68.        "foo", etc.
  69.  
  70. '+'    An expression followed by a plus sign matches one or more
  71.        occurrances of that expression: "fo+" matches "fo", etc.
  72.  
  73. '-'    An expression followed by a minus sign optionally matches
  74.        the expression.
  75.  
  76. '[]'   A string enclosed in square brackets matches any character in
  77.        that string, but no others.  If the first character in the
  78.        string is a circumflex, the expression matches any character
  79.        except "new-line" and the characters in the string.  For
  80.        example, "[xyz]" matches "xx" and "zyx", while "[^xyz]"
  81.        matches "abc" but not "axb".  A range of characters may be
  82.        specified by two characters separated by "-".  Note that,
  83.        [a-z] matches alphabetics, while [z-a] never matches.
  84.  
  85. The concatenation of regular expressions is a regular expression.
  86.